package com.xiaoy.util;

import java.util.Locale;

import javax.servlet.http.HttpSession;

import freemarker.template.Configuration;

public class FreeMarkerUtil {

	
	protected static Configuration cfg = null;
	
	private static FreeMarkerUtil freeMarker = new FreeMarkerUtil();
	
//	public FreeMarkerUtil(HttpSession session) {
//		Configuration c = getInstance ();
//		c.setServletContextForTemplateLoading(session.getServletContext(), "/");
//		c.setEncoding(Locale.getDefault(), "utf-8");
//	}
	
	private FreeMarkerUtil () {
		cfg = new Configuration();
	}
	
	public static Configuration initFreeMarker (HttpSession session) {
		
		cfg.setServletContextForTemplateLoading(session.getServletContext(), "/");
		cfg.setEncoding(Locale.getDefault(), "utf-8");
		return cfg;
	}
	
	public static FreeMarkerUtil getInstance () {
		
		return freeMarker;
	}
	
	
	
}


